export const getDistance = (lat1, lng1, lat2, lng2) => {
  var radLat1 = rad(lat1);
  var radLat2 = rad(lat2);
  var a = radLat1 - radLat2;
  var b = rad(lng1) - rad(lng2);
  var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
      Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  s = s * 6378.137; // EARTH_RADIUS;
  // 输出为公里
  s = Math.round(s * 10000) / 10000;

  var distance = s;
  var distanceStr = "";

  if (parseInt(distance) >= 1) {
    distanceStr = distance.toFixed(2) + "km";
  } else {
    distanceStr = (distance * 1000).toFixed(2) + "m";
  }
  // 小小修改，这里返回对象
  let objData = {
    distance: distance,
    distanceStr: distanceStr
  }
  return objData
}
function rad(d) {
  return d * Math.PI / 180.0;
}